﻿using Abp.Dependency;
using Abp.EntityFrameworkCore;
using Paas.Core;
using Basefr.Core.Contracts;
using Basefr.Core.Entities;
using Basefr.Data.EntityFrameworkCore;

namespace Paas.Infrastructure.Data.EntityFrameworkCore
{
    public class MainRepository<TEntity, TPrimaryKey> : Repository<MainDbContext, TEntity, TPrimaryKey>, IMainRepository<TEntity, TPrimaryKey>
        where TEntity : EntityBase<TPrimaryKey>
        where TPrimaryKey : struct
    {
        public MainRepository(IDbContextProvider<MainDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }
    }


    public class MainRepository<TEntity> : Repository<MainDbContext, TEntity, int>, IMainRepository<TEntity>
        where TEntity : EntityBase<int>
    {
        public MainRepository(IDbContextProvider<MainDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }
    }


    public class MainRepository : Repository, IMainRepository
    {
        private readonly IIocResolver _iocResolver;

        public MainRepository(IIocResolver iocResolver)
        {
            _iocResolver = iocResolver;
        }

        public override IRepository<TEntity, int> GetRepository<TEntity>()
        {
            return _iocResolver.Resolve<IMainRepository<TEntity>>();
        }
    }

}

